package com.chinasoft.mall.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;

import com.chinasoft.mall.activity.LoadingActivity;
import com.chinasoft.mall.activity.WidgetActivity;
import com.chinasoft.mall.service.PushMessageService;
import com.chinasoft.mall.service.UpdateService;

public class myBroadCast extends BroadcastReceiver {
//	系统启动完成后会调用
	public static final String BOOT_COMPLETED_ACTION = "android.intent.action.BOOT_COMPLETED";
	
	public static final String ACTION_INTENT_TEST = "com.broadcast.test";

	public myBroadCast() {
		Log.v("BROADCAST_TAG", "myBroadCast");
	}

	@Override
	public void onReceive(Context context, Intent intent) {
		// TODO Auto-generated method stub

		Log.v("BROADCAST_TAG", "onReceive");
		String action = intent.getAction();
		if (TextUtils.equals(action, BOOT_COMPLETED_ACTION)) {
			// 系统启动完成后会调用
			// Intent _intent=new Intent();
			Toast.makeText(context, "开机启动", Toast.LENGTH_LONG).show();
			Intent startServiceIntent = new Intent();
			startServiceIntent.setClass(context,
					PushMessageService.class);
			context.startService(startServiceIntent);
			return;
		} else if (TextUtils.equals(action, ACTION_INTENT_TEST)){
			//加逻辑判断
			Log.e("tag", "弹出窗口=======");
			intent.setClass(context, WidgetActivity.class);
			intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			context.startActivity(intent);
			
//			LayoutInflater mLayoutInflater = (LayoutInflater) context
//                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//            View music_popunwindwow = mLayoutInflater.inflate(
//                    R.layout.showplaying, null);
//            PopupWindow mPopupWindow = new PopupWindow(music_popunwindwow, LayoutParams.FILL_PARENT,
//                    LayoutParams.WRAP_CONTENT);
//            
//            mPopupWindow.showAtLocation(parent, Gravity.RIGHT|Gravity.BOTTOM, 0, 0);

		}
	}
}